<docs>
  ## 求职意向详情
</docs>
<template>
  <div>
         <!-- 背景图 -->
    <div class="beijingtu"></div>
    <div class="bg_g">
      <!-- 基本个人信息 -->
      <div class="box1">
        <co-form :model="data" :rules="rules" ref="form">
          <div class="box3 boild">
            <div class="mar">期望求职地点</div>
            <!-- 选择地址层级 开始 所在区 -->
            <div class="picker" ref="picker">
              <span id="trigger2" class="_input padd" v-model="data.qwqzdd"  style>{{data.qwqzddmc}}</span>
            </div>
          </div>
          <!-- 期望行业-->
          <div class="box3 boild">
            <div class="describe">期望行业</div>
            <co-select class="clearfix" prop="qwhy" :list="qwhyList" v-model="data.qwhy"></co-select>
          </div>
          <!--期望岗位  -->
          <div class="box3 boild">
            <div class="describe">期望岗位</div>
            <co-input prop="qwgws" v-model="data.qwgws[0]" placeholder="请输入"></co-input>
          </div>
          <!-- 期望月薪 -->
          <div class="box3 clearfix noob" style="padding-bottom:0.32rem">
            <div class="describe">期望月薪</div>
            <co-input
              type="number"
              class="c_input"
              prop="qwxzq"
              v-model="data.qwxzq"
              placeholder="请输入"
            ></co-input>
            <div class="zhi clearfix">元至</div>
            <co-input
              type="number"
              prop="qwxzz"
              v-model="data.qwxzz"
              placeholder="请输入"
              class="c_input"
            ></co-input>
            <div class="zhi clearfix">元</div>
          </div>
        </co-form>
      </div>
    </div>
    <!-- <div class="he" style="height:5rem"></div> -->
    <div class="bottom"></div>
    <!-- 底部保存 -->
    <div class="info-bottom">
      <button data-v-347f2e5d type="button" class="bc" @click="qzyxbc">保&nbsp;&nbsp;存</button>
    </div>
  </div>
</template>
<script>
import $ from "@/common/js/axios";
import coForm from "@/base/form/form";
import coInput from "@/base/form/input";
import coSelect from "@/base/form/select";
import PickerExtend from "picker-extend"; //行政区划插件
import { validator } from "@/common/js/valid";
import { mixinValid } from "@/common/mixins/mixins";
export default {
  components: { coInput, coSelect, coForm },
  mixins: [mixinValid],
  data() {
    return {
      //城市区划代码表
      csList: [],
      qzyxid: "",
      //单位行业代码表
      qwhyList: [],
      positionArr:[],
      /// 行政区划列表
      xzqhlb: "", //
      data: {
        qyxid: "", //类型：String  必有字段  备注：14,full,求职意向ID,true
        qwqzdd: "", //类型：String  必有字段  备注：12,number,期望求职地点,false
        qwhy: "", //类型：String  必有字段  备注：2,number,期望行业,false
        qwgws: [], //类型：Array  必有字段  备注：20,full,期望岗位,false
        qwxzq: "", //类型：String  必有字段  备注：10,number,期望薪资起,false
        qwxzz: "" //类型：String  必有字段  备注：10number,期望薪资止,false
      },
      rules: {
        qwqzdd: validator('12,"number","期望求职地点",false'),
        qwhy: validator('30,"full","期望行业",false'),
        qwgws: validator('20,"full","期望岗位",false'),
        qwxzq: validator('10,"number","期望薪资起",false'),
        qwxzz: validator('10,"number","期望薪资止",false')
      }
    };
  },
  computed: {},
  methods: {
    // 求职意向查询
    qzyxCx() {
      this.$loading = true;
      $.get("/wdjl/qzyxCx?qzyxid=" + this.qzyxid).then(res => {
        if(res.returnData.executeResult=="1"&&res.returnData.qzyx){
            this.data = res.returnData.qzyx;
        }
        this.$loading = false;
      });
    },
    //获取行业
    getjob() {
      $.get("/dmb/dmblbCx", { params: { dmbmc: "cdg_industry" } }).then(res => {
        this.qwhyList = res.returnData.dmblb;
      });
    },
    // 获取行政区划代码表
    getaddList() {
      $.get("/dmb/xzyh2jCx").then(res => {
        // 获取到数组值
        this.csList = res.returnData.xzqhlb;
         let posiArr = this.randerPosition(this.csList,this.data.qwqzdd);  // 声明一个变量  调用方法  传入行政区划代码表数组    市级id
        this.xzqh(this.csList,posiArr);    // 调用方法  第一个值是行政区划代码表数组   第二个是回显所需要的数组里面的数据下标
      });
    },
      randerPosition(all, tarid) {
      let _tarid = tarid || "110000000000";    // 市的id值
      let _item1 = _tarid.substring(0, 3) + "000000000";   // 省的id值
      this.dgArr(all, _item1);
      this.dgArr(all, _tarid);
      return this.positionArr;
    },
    dgArr(all, str) {
      all.forEach((item, index) => {
        if (item.id == str) {
          this.positionArr.push(index);
          return;
        } else if (item.children) {
          this.dgArr(item.children, str);
        }
      });
    },
    // 调用行政区划方法   qwqz = 期望求职
    xzqh(addList,posi) {
      var _this = this;
      var _position = posi || [0, 0];
      var pickerExtend = new PickerExtend({
        trigger: "#trigger2",
        title: "请选择",
        wheels: [{ data: addList }],
        keyMap: {
          id: "id",
          value: "name",
          childs: "children"
        },
        flexibleHeight: "80",
        connector: "",
        position: _position,
        callback: function(indexarr, data) {
          // 市 Id 传给后台
          _this.data.qwqzdd = data[1].id;
        }
      });
    },
    // 保存求职意向接口
    qzyxbc() {
      if (Number(this.data.qwxzq) > Number(this.data.qwxzz)) {
        this.$alert({
          type: "warning",
          message: "最低工资不得大于最高工资"
        });
        return false;
      } else {
        this.$refs.form.validate(() => {
          $.post("/wdjl/qzyxBc", this.data).then(res => {
            if (res.returnData.executeResult == "1") {
              this.$alert(
                {
                  type: "success",
                  message: res.returnData.message
                },
                () => {
                  this.$router.push({ path: "/cvitae" });
                }
              );
            } else {
              this.$alert({
                type: "warning",
                message: res.returnData.message
              });
            }
          });
        });
      }
    }
  },
  created() {
    this.getjob();
    //获取代码表
    let id = this.$route.query.qzyxid;
    this.qzyxid = id;
    if(id){
      this.qzyxCx()
    }
    id ? this.qzyxCx() : this.data.qwqzddmc = "请选择"
  },
  mounted() {
    this.getaddList();
    //  this.get_xzqh();
  }
};
</script>
<style lang="scss" scoped>
@import "~common/scss/var.scss";

.boild::after {
  content: " ";
  display: inline-block;
  width: 85%;
  border-bottom: 1px solid rgba(229, 229, 229, 1);
  position: absolute;
  top: 105%;
  // right: 0.64rem;
}
.focusState {
  position: absolute;
}
.zhi {
  float: left;
  // margin-left:-10px;
  margin-top: 10px;
  font-size: 32px;
}
.no-left {
  margin-left: 0;
}
.c_input {
  width: 40%;
  float: left;
  margin-left: 10px;
}
.bg_g {
  padding: 0 34px;
  overflow: hidden;
  position: relative;
}
.padd {
  font-weight: bold;
  font-size: 32px;
  // margin: 20px 0 66px 32px;
  display: block;
  color: #333333;
}
.weui-cell_select-after {
  width: 100%;
}
.beijingtu {
  width: 100%;
  height: 880px;
  background: url("../../common/images/beijing.png") no-repeat;
  background-size: 100% 100%;
  position: absolute;
  z-index: -9000;
  margin-top: -210px;
}
.bottom {
  width: 100%;
  height: 190px;
  background: url("../../common/images/dbg.png") no-repeat;
  background-size: 100%;
  position: fixed;
  bottom: 0;
  // margin-top: 4rem;
}
.mar {
  font-size: $font-size-base;
  margin: 20px 0 20px 0px;
  // font-weight: bold;
  color: #666666;
}
.describe {
  font-size: $font-size-base;
  margin: 20px 0 0px 0px;
  // font-weight: bold;
  color: #666666;
}
.box2 {
  padding: 0px 38px 20px 38px;
  // margin-bottom: 20px;
  position: relative;
}
.box3 {
  // margin-bottom: 40px;
  padding: 20px 38px 20px 38px;
  position: relative;
}
.box1 {
  padding: 15px 0;
  margin: 40px auto;
  margin-bottom: 3rem;
  background: white;
  overflow: hidden;
  border-radius: 4px;
  position: relative;
}
</style>
